package cn.xyy.system.api;

import cn.xyy.system.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.xyy.common.domain.system.auth.Job;
import cn.xyy.common.domain.system.auth.JobVO;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.xyy.common.annotation.log.Log;
import cn.xyy.common.domain.mvc.R;

/**
 * 岗位接口
 * 
 * @author xyy
 *
 */
@RestController
@RequestMapping(value = "/rest/job")
public class JobRest {
	@Autowired
	private JobService jobService;

	@RequestMapping(value = "getJobPage", method = RequestMethod.POST)
	public R getJobPage(@RequestBody JobVO vo) {
		return R.ok(jobService.getJobPage(vo));

	}

	@RequestMapping(value = "getJobList")
	public R getList() {
		return R.ok(jobService.getJobList());

	}

	@Log("添加岗位")
	@SaCheckPermission("job:add")
	@RequestMapping(value = "add", method = RequestMethod.POST)
	public R add(@RequestBody Job job) {
		jobService.add(job);
		return R.ok();
	}

	@Log("修改岗位")
	@SaCheckPermission("job:edit")
	@RequestMapping(value = "update", method = RequestMethod.POST)
	public R update(@RequestBody JobVO vo) {
		jobService.update(vo);
		return R.ok();
	}

	@Log("删除岗位")
	@SaCheckPermission("job:del")
	@RequestMapping(value = "delete")
	public R delete(@RequestParam("id") String id) {
		jobService.delete(id);
		return R.ok();
	}

	@Log("更新岗位状态")
	@RequestMapping(value = "updateState", method = RequestMethod.POST)
	public R updateState(@RequestBody Job job) {
		jobService.updateState(job);
		return R.ok();

	}
}
